const babelCore = require('@babel/core')

const code = `
    let person = {
        username: 'Lucy',
        age: '23'
    }

    let arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

    let {username, age} = person
    let [a, b, ...rest] = arr
`
const result = babelCore.transformSync(code,{
    plugins: ["@babel/plugin-transform-destructuring"]
})

console.log(result.code);